import com.tech.common.KuduUtil.{ruleTable, session}

import java.sql.{Connection, DriverManager}
import java.text.SimpleDateFormat
import scala.collection.mutable

object Test0729 {

  def main(args: Array[String]): Unit = {

    val value = "17\tisreceived_phone\t是否接收电话1\tDimension trueOrFalse 0\t\t\t0\tisreceived_phone"
    val strings = value.split("\t")
    //id	project	attribute_key	name	data_type	data_source	enable_update	event_key	update_mode	is_show	en_name
    val connection: Connection = DriverManager.getConnection("jdbc:mysql://52.130.94.89:63306/shdev_datanow?user=shdev&password=P@ssw0rd`123&useSSL=false&requireSSL=true")
    val statement = connection.createStatement()
    val set = statement.executeQuery {
      "SELECT autoid,attributekey,name,datatype,datasource,enableupdate,eventkey,updatemode,isshow,enName FROM customerproperties where eventkey is not null"
    }
    while (set.next()) {
      //autoid	attributekey	name	datatype	datasource	enableupdate	eventkey	updatemode	isshow	enName
      val upsert = ruleTable.newUpsert()
      val row = upsert.getRow
      row.addString("project", "ndev")
      row.addLong("id", set.getInt("autoid"))
      row.addString("attribute_key", set.getString("attributekey"))
      row.addString("name", set.getString("name"))
      row.addString("data_type", set.getString("datatype"))
      row.addString("data_source", set.getString("datasource"))
      row.addInt("enable_update", set.getInt("enableupdate"))
      row.addString("event_key", set.getString("eventkey"))
      row.addString("update_mode", set.getString("updatemode"))
      row.addInt("is_show", set.getInt("isshow"))
      if (set.getString("enName") != null)
        row.addString("en_name", set.getString("enName"))
      session.apply(upsert)
      session.flush()
    }


    println(set.getRow)


    //17	isreceived_phone  是否接收电话1	Dimension trueOrFalse 0		  0	isreceived_phone
    //18	isreceived_sms	接收短信		trueOrFalse	0			0	isreceived_sms
    //19	isreceived_email	接收邮件		trueOrFalse	0			0	isreceived_email
    //23	is_member	是否会员	Dimension	trueOrFalse	1	$signup	replace	0	is_member
    //24	event_time	绑定时间	DateTime		1	$binding	replace	1	event_time
    //26	first_store	入会门店	Dimension	store	0			1	first_store
    //28	name	昵称	String		1	$signup	replace	1	name
    //31	correlation_type	相关类型		consumptionType	1	$order	replace	0	correlation_type
    //37	status	会员状态	Dimension	memberStatus	1	$update	replace	1
    //49	birthday	生日			1	$signoff	replace	1
    //50	gender	性别	Dimension	gender	1	$signup	replace	1
    //53	mobilephone	手机号	String		0			1
    //58	created_time	数据创建时间	DateTime		0			0
    //61	age_group	年龄段	Dimension	memberStatus	0			0
    //65	total_point	总积分	Decimal		1	$order	addup	1
    //68	is_intact	是否整单	Dimension	trueOrFalse	1	$order	replace	0
    //69	description	范金泉	String		0			0
    //70	source	来源范金泉	Dimension	entryChannel	0			0
    //77	email	电子邮箱	String		1	$update	replace	0
    //79	province	省份	Dimension	province	1	$behavior	replace	1
    //80	channel	注册渠道	Dimension	behaviorChannel	0			1

  }

}
